package com.google.android.material.bottomnavigation;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable.ConstantState;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import androidx.annotation.StyleRes;
import androidx.core.view.ViewCompat;
import androidx.core.widget.TextViewCompat;
import o.aqu.a;
import o.aqu.c;
import o.aqu.j;
import o.bj;
import o.bo.b;
import o.cz;
import o.fo;
import o.gg;
import o.hz;

@RestrictTo({d.LIBRARY_GROUP})
public class BottomNavigationItemView extends FrameLayout implements b {
    private static final int[] ˏ = new int[]{16842912};
    private final TextView ʻ;
    private int ʼ;
    private final TextView ʽ;
    private float ˊ;
    private bj ˊॱ;
    private final int ˋ;
    private int ˋॱ;
    private float ˎ;
    private float ॱ;
    private ColorStateList ॱˊ;
    private ImageView ॱॱ;
    private boolean ᐝ;

    public BottomNavigationItemView(@NonNull Context context) {
        this(context, null);
    }

    public BottomNavigationItemView(@NonNull Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public BottomNavigationItemView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.ˋॱ = -1;
        Resources resources = getResources();
        LayoutInflater.from(context).inflate(i.ˏ, this, true);
        setBackgroundResource(a.ˎ);
        this.ˋ = resources.getDimensionPixelSize(c.ॱॱ);
        this.ॱॱ = (ImageView) findViewById(j.ॱ);
        this.ʽ = (TextView) findViewById(j.ʼ);
        this.ʻ = (TextView) findViewById(j.ᐝ);
        ViewCompat.setImportantForAccessibility(this.ʽ, 2);
        ViewCompat.setImportantForAccessibility(this.ʻ, 2);
        setFocusable(true);
        ˏ(this.ʽ.getTextSize(), this.ʻ.getTextSize());
    }

    public void ॱ(bj bjVar, int i) {
        this.ˊॱ = bjVar;
        setCheckable(bjVar.isCheckable());
        setChecked(bjVar.isChecked());
        setEnabled(bjVar.isEnabled());
        setIcon(bjVar.getIcon());
        setTitle(bjVar.getTitle());
        setId(bjVar.getItemId());
        if (!TextUtils.isEmpty(bjVar.getContentDescription())) {
            setContentDescription(bjVar.getContentDescription());
        }
        cz.ˋ(this, bjVar.getTooltipText());
        setVisibility(bjVar.isVisible() ? 0 : 8);
    }

    public void setItemPosition(int i) {
        this.ˋॱ = i;
    }

    public void setShifting(boolean z) {
        if (this.ᐝ != z) {
            this.ᐝ = z;
            if ((this.ˊॱ != null ? 1 : null) != null) {
                setChecked(this.ˊॱ.isChecked());
            }
        }
    }

    public void setLabelVisibilityMode(int i) {
        if (this.ʼ != i) {
            this.ʼ = i;
            if ((this.ˊॱ != null ? 1 : null) != null) {
                setChecked(this.ˊॱ.isChecked());
            }
        }
    }

    public bj ˏ() {
        return this.ˊॱ;
    }

    public void setTitle(CharSequence charSequence) {
        this.ʽ.setText(charSequence);
        this.ʻ.setText(charSequence);
        if (this.ˊॱ == null || TextUtils.isEmpty(this.ˊॱ.getContentDescription())) {
            setContentDescription(charSequence);
        }
    }

    public void setCheckable(boolean z) {
        refreshDrawableState();
    }

    public void setChecked(boolean z) {
        this.ʻ.setPivotX((float) (this.ʻ.getWidth() / 2));
        this.ʻ.setPivotY((float) this.ʻ.getBaseline());
        this.ʽ.setPivotX((float) (this.ʽ.getWidth() / 2));
        this.ʽ.setPivotY((float) this.ʽ.getBaseline());
        switch (this.ʼ) {
            case -1:
                if (!this.ᐝ) {
                    if (!z) {
                        ˊ(this.ॱॱ, this.ˋ, 49);
                        ॱ(this.ʻ, this.ˊ, this.ˊ, 4);
                        ॱ(this.ʽ, 1.0f, 1.0f, 0);
                        break;
                    }
                    ˊ(this.ॱॱ, (int) (((float) this.ˋ) + this.ˎ), 49);
                    ॱ(this.ʻ, 1.0f, 1.0f, 0);
                    ॱ(this.ʽ, this.ॱ, this.ॱ, 4);
                    break;
                }
                if (z) {
                    ˊ(this.ॱॱ, this.ˋ, 49);
                    ॱ(this.ʻ, 1.0f, 1.0f, 0);
                } else {
                    ˊ(this.ॱॱ, this.ˋ, 17);
                    ॱ(this.ʻ, 0.5f, 0.5f, 4);
                }
                this.ʽ.setVisibility(4);
                break;
            case 0:
                if (z) {
                    ˊ(this.ॱॱ, this.ˋ, 49);
                    ॱ(this.ʻ, 1.0f, 1.0f, 0);
                } else {
                    ˊ(this.ॱॱ, this.ˋ, 17);
                    ॱ(this.ʻ, 0.5f, 0.5f, 4);
                }
                this.ʽ.setVisibility(4);
                break;
            case 1:
                if (!z) {
                    ˊ(this.ॱॱ, this.ˋ, 49);
                    ॱ(this.ʻ, this.ˊ, this.ˊ, 4);
                    ॱ(this.ʽ, 1.0f, 1.0f, 0);
                    break;
                }
                ˊ(this.ॱॱ, (int) (((float) this.ˋ) + this.ˎ), 49);
                ॱ(this.ʻ, 1.0f, 1.0f, 0);
                ॱ(this.ʽ, this.ॱ, this.ॱ, 4);
                break;
            case 2:
                ˊ(this.ॱॱ, this.ˋ, 17);
                this.ʻ.setVisibility(8);
                this.ʽ.setVisibility(8);
                break;
        }
        refreshDrawableState();
        setSelected(z);
    }

    private void ˊ(@NonNull View view, int i, int i2) {
        LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
        layoutParams.topMargin = i;
        layoutParams.gravity = i2;
        view.setLayoutParams(layoutParams);
    }

    private void ॱ(@NonNull View view, float f, float f2, int i) {
        view.setScaleX(f);
        view.setScaleY(f2);
        view.setVisibility(i);
    }

    public void setEnabled(boolean z) {
        super.setEnabled(z);
        this.ʽ.setEnabled(z);
        this.ʻ.setEnabled(z);
        this.ॱॱ.setEnabled(z);
        if (z) {
            ViewCompat.ˋ(this, hz.ॱ(getContext(), 1002));
        } else {
            ViewCompat.ˋ(this, null);
        }
    }

    public int[] onCreateDrawableState(int i) {
        int[] onCreateDrawableState = super.onCreateDrawableState(i + 1);
        if (this.ˊॱ != null && this.ˊॱ.isCheckable() && this.ˊॱ.isChecked()) {
            mergeDrawableStates(onCreateDrawableState, ˏ);
        }
        return onCreateDrawableState;
    }

    public void setShortcut(boolean z, char c) {
    }

    public void setIcon(Drawable drawable) {
        if (drawable != null) {
            ConstantState constantState = drawable.getConstantState();
            if (constantState != null) {
                drawable = constantState.newDrawable();
            }
            drawable = gg.ʻ(drawable).mutate();
            gg.ॱ(drawable, this.ॱˊ);
        }
        this.ॱॱ.setImageDrawable(drawable);
    }

    public boolean a_() {
        return false;
    }

    public void setIconTintList(ColorStateList colorStateList) {
        this.ॱˊ = colorStateList;
        if (this.ˊॱ != null) {
            setIcon(this.ˊॱ.getIcon());
        }
    }

    public void setIconSize(int i) {
        LayoutParams layoutParams = (LayoutParams) this.ॱॱ.getLayoutParams();
        layoutParams.width = i;
        layoutParams.height = i;
        this.ॱॱ.setLayoutParams(layoutParams);
    }

    public void setTextAppearanceInactive(@StyleRes int i) {
        TextViewCompat.ˎ(this.ʽ, i);
        ˏ(this.ʽ.getTextSize(), this.ʻ.getTextSize());
    }

    public void setTextAppearanceActive(@StyleRes int i) {
        TextViewCompat.ˎ(this.ʻ, i);
        ˏ(this.ʽ.getTextSize(), this.ʻ.getTextSize());
    }

    public void setTextColor(@Nullable ColorStateList colorStateList) {
        if (colorStateList != null) {
            this.ʽ.setTextColor(colorStateList);
            this.ʻ.setTextColor(colorStateList);
        }
    }

    private void ˏ(float f, float f2) {
        this.ˎ = f - f2;
        this.ॱ = (1.0f * f2) / f;
        this.ˊ = (1.0f * f) / f2;
    }

    public void setItemBackground(int i) {
        Drawable drawable;
        if (i == 0) {
            drawable = null;
        } else {
            drawable = fo.ˊ(getContext(), i);
        }
        setItemBackground(drawable);
    }

    public void setItemBackground(@Nullable Drawable drawable) {
        ViewCompat.ˏ(this, drawable);
    }
}
